class Solution:
    """
    53. 最大子序和
    https://leetcode-cn.com/problems/maximum-subarray/
    @date: 2021年1月2日23:18:19
    @author: mizzle rain
    """

    def maxSubArray(self, nums):
        n = len(nums)
        if n == 0:
            return 0
        dp = [0]*n
        dp[0] = nums[0]
        for i in range(1, n):
            dp[i] = max(nums[i], dp[i-1]+nums[i])
        return max(dp)
